{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Client\n",
    "\n",
    "Demo of a client interacting with a custom runnable executor that supports configuration.\n",
    "\n",
    "This server does not support invoke or batch! only stream and astream log! (see backend code.)\n",
    "\n",
    "The underlying backend code is just a demo in this case -- it's working around an existing bug, but uses \n",
    "the opportunity to show how to create custom runnables."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can interact with this via API directly"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "event: metadata\n",
      "data: {\"run_id\": \"5e6ce60a-95c4-4fe5-8c4a-ec1d347afd83\"}\n",
      "\n",
      "event: data\n",
      "data: {\"actions\":[{\"tool\":\"get_eugene_thoughts\",\"tool_input\":{\"query\":\"cats\"},\"log\":\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\",\"type\":\"AgentActionMessageLog\",\"message_log\":[{\"content\":\"\",\"additional_kwargs\":{\"function_call\":{\"name\":\"get_eugene_thoughts\",\"arguments\":\"{\\n  \\\"query\\\": \\\"cats\\\"\\n}\"}},\"type\":\"ai\",\"example\":false}]}],\"messages\":[{\"content\":\"\",\"additional_kwargs\":{\"function_call\":{\"name\":\"get_eugene_thoughts\",\"arguments\":\"{\\n  \\\"query\\\": \\\"cats\\\"\\n}\"}},\"type\":\"ai\",\"example\":false}]}\n",
      "\n",
      "event: data\n",
      "data: {\"steps\":[{\"action\":{\"tool\":\"get_eugene_thoughts\",\"tool_input\":{\"query\":\"cats\"},\"log\":\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\",\"type\":\"AgentActionMessageLog\",\"message_log\":[{\"content\":\"\",\"additional_kwargs\":{\"function_call\":{\"name\":\"get_eugene_thoughts\",\"arguments\":\"{\\n  \\\"query\\\": \\\"cats\\\"\\n}\"}},\"type\":\"ai\",\"example\":false}]},\"observation\":[{\"page_content\":\"cats like fish\",\"metadata\":{},\"type\":\"Document\"},{\"page_content\":\"dogs like sticks\",\"metadata\":{},\"type\":\"Document\"}]}],\"messages\":[{\"content\":\"[Document(page_content='cats like fish'), Document(page_content='dogs like sticks')]\",\"additional_kwargs\":{},\"type\":\"function\",\"name\":\"get_eugene_thoughts\"}]}\n",
      "\n",
      "event: data\n",
      "data: {\"output\":\"Eugene thinks that cats like fish.\",\"messages\":[{\"content\":\"Eugene thinks that cats like fish.\",\"additional_kwargs\":{},\"type\":\"ai\",\"example\":false}]}\n",
      "\n",
      "event: end\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "\n",
    "inputs = {\"input\": {\"input\": \"what does eugene think of cats?\"}}\n",
    "response = requests.post(\"http://localhost:8000/stream\", json=inputs)\n",
    "\n",
    "print(response.text)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can also interact with this via the RemoteRunnable interface (to use in other chains)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from langserve import RemoteRunnable\n",
    "\n",
    "remote_runnable = RemoteRunnable(\"http://localhost:8000/\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Remote runnable has the same interface as local runnables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'output': 'Hello! How can I assist you today?', 'messages': [AIMessage(content='Hello! How can I assist you today?')]}\n"
     ]
    }
   ],
   "source": [
    "async for chunk in remote_runnable.astream({\"input\": \"hi!\"}):\n",
    "    print(chunk)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "RunLogPatch({'op': 'replace',\n",
      "  'path': '',\n",
      "  'value': {'final_output': None,\n",
      "            'id': '9f415b49-ba69-4fdf-9b9c-5ccc1805487f',\n",
      "            'logs': {},\n",
      "            'streamed_output': []}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/RunnableSequence',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '95a0ba72-9511-4fff-8b8c-410e7108ee60',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'RunnableSequence',\n",
      "            'start_time': '2024-01-06T03:12:42.213+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': [],\n",
      "            'type': 'chain'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/RunnableParallel<input,agent_scratchpad>',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': 'a0afa5a6-a408-4a2d-83f8-8e4c8193f963',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'RunnableParallel<input,agent_scratchpad>',\n",
      "            'start_time': '2024-01-06T03:12:42.214+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['seq:step:1'],\n",
      "            'type': 'chain'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/<lambda>',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '2aed7d13-2d0b-4c37-a4b3-d3f266bbf7e6',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': '<lambda>',\n",
      "            'start_time': '2024-01-06T03:12:42.215+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['map:key:input'],\n",
      "            'type': 'chain'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/<lambda>:2',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '9328b5cf-fd7b-48fe-affb-2973643189e9',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': '<lambda>',\n",
      "            'start_time': '2024-01-06T03:12:42.215+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['map:key:agent_scratchpad'],\n",
      "            'type': 'chain'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/<lambda>/final_output',\n",
      "  'value': {'output': 'what does eugene think about cats?'}},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/<lambda>/end_time',\n",
      "  'value': '2024-01-06T03:12:42.217+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/<lambda>:2/final_output',\n",
      "  'value': {'output': []}},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/<lambda>:2/end_time',\n",
      "  'value': '2024-01-06T03:12:42.217+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/RunnableParallel<input,agent_scratchpad>/final_output',\n",
      "  'value': {'agent_scratchpad': [],\n",
      "            'input': 'what does eugene think about cats?'}},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/RunnableParallel<input,agent_scratchpad>/end_time',\n",
      "  'value': '2024-01-06T03:12:42.218+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/ChatPromptTemplate',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': 'a08bec71-bf7f-46c5-b082-14f7bff421cd',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'ChatPromptTemplate',\n",
      "            'start_time': '2024-01-06T03:12:42.219+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['seq:step:2'],\n",
      "            'type': 'prompt'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/ChatPromptTemplate/final_output',\n",
      "  'value': {'messages': [SystemMessage(content='You are a helpful assistant.'),\n",
      "                         HumanMessage(content='what does eugene think about cats?')]}},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/ChatPromptTemplate/end_time',\n",
      "  'value': '2024-01-06T03:12:42.219+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/LLM',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': 'bf859261-467b-44b3-84fb-80d8c9e9dff2',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'LLM',\n",
      "            'start_time': '2024-01-06T03:12:42.221+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['seq:step:3'],\n",
      "            'type': 'llm'}})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': ''}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': '{\\n'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': ' '}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': ' \"'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': 'query'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': '\":'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': ' \"'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': 'cats'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': '\"\\n'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': '}'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='')})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/LLM/final_output',\n",
      "  'value': LLMResult(generations=[[ChatGeneration(generation_info={'finish_reason': 'function_call'}, message=AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}}))]], llm_output=None, run=None)},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/end_time',\n",
      "  'value': '2024-01-06T03:12:42.806+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/OpenAIFunctionsAgentOutputParser',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': 'd635ccbb-1db3-4515-b1ca-0c14752d361a',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'OpenAIFunctionsAgentOutputParser',\n",
      "            'start_time': '2024-01-06T03:12:42.807+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['seq:step:4'],\n",
      "            'type': 'parser'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/OpenAIFunctionsAgentOutputParser/final_output',\n",
      "  'value': AgentActionMessageLog(tool='get_eugene_thoughts', tool_input={'query': 'cats'}, log=\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})])},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/OpenAIFunctionsAgentOutputParser/end_time',\n",
      "  'value': '2024-01-06T03:12:42.809+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/RunnableSequence/final_output',\n",
      "  'value': {'output': AgentActionMessageLog(tool='get_eugene_thoughts', tool_input={'query': 'cats'}, log=\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})])}},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/RunnableSequence/end_time',\n",
      "  'value': '2024-01-06T03:12:42.809+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/streamed_output/-',\n",
      "  'value': {'actions': [AgentActionMessageLog(tool='get_eugene_thoughts', tool_input={'query': 'cats'}, log=\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})])],\n",
      "            'messages': [AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})]}},\n",
      " {'op': 'replace',\n",
      "  'path': '/final_output',\n",
      "  'value': {'actions': [AgentActionMessageLog(tool='get_eugene_thoughts', tool_input={'query': 'cats'}, log=\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})])],\n",
      "            'messages': [AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})]}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/get_eugene_thoughts',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '5eecdbe8-3374-4f0e-8ae8-d8a7e2394ae1',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'get_eugene_thoughts',\n",
      "            'start_time': '2024-01-06T03:12:42.810+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': [],\n",
      "            'type': 'tool'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/get_eugene_thoughts/final_output',\n",
      "  'value': {'output': \"[Document(page_content='cats like fish'), \"\n",
      "                      \"Document(page_content='dogs like sticks')]\"}},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/get_eugene_thoughts/end_time',\n",
      "  'value': '2024-01-06T03:12:43.095+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/streamed_output/-',\n",
      "  'value': {'messages': [FunctionMessage(content=\"[Document(page_content='cats like fish'), Document(page_content='dogs like sticks')]\", name='get_eugene_thoughts')],\n",
      "            'steps': [{'action': AgentActionMessageLog(tool='get_eugene_thoughts', tool_input={'query': 'cats'}, log=\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})]),\n",
      "                       'observation': [Document(page_content='cats like fish'),\n",
      "                                       Document(page_content='dogs like sticks')]}]}},\n",
      " {'op': 'add',\n",
      "  'path': '/final_output/steps',\n",
      "  'value': [{'action': AgentActionMessageLog(tool='get_eugene_thoughts', tool_input={'query': 'cats'}, log=\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})]),\n",
      "             'observation': [Document(page_content='cats like fish'),\n",
      "                             Document(page_content='dogs like sticks')]}]},\n",
      " {'op': 'add',\n",
      "  'path': '/final_output/messages/1',\n",
      "  'value': FunctionMessage(content=\"[Document(page_content='cats like fish'), Document(page_content='dogs like sticks')]\", name='get_eugene_thoughts')})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/RunnableSequence:2',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '89bf8195-df48-4fde-81b0-9e1982051caa',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'RunnableSequence',\n",
      "            'start_time': '2024-01-06T03:12:43.097+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': [],\n",
      "            'type': 'chain'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/RunnableParallel<input,agent_scratchpad>:2',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '567c178a-4897-4865-af27-7122432df7bd',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'RunnableParallel<input,agent_scratchpad>',\n",
      "            'start_time': '2024-01-06T03:12:43.098+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['seq:step:1'],\n",
      "            'type': 'chain'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/<lambda>:3',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '03530072-e5b2-4d7e-b875-f77e3d47481b',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': '<lambda>',\n",
      "            'start_time': '2024-01-06T03:12:43.099+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['map:key:input'],\n",
      "            'type': 'chain'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/<lambda>:4',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': 'c554e615-1b70-4dc1-a4aa-aa09ccdacb09',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': '<lambda>',\n",
      "            'start_time': '2024-01-06T03:12:43.099+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['map:key:agent_scratchpad'],\n",
      "            'type': 'chain'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/<lambda>:3/final_output',\n",
      "  'value': {'output': 'what does eugene think about cats?'}},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/<lambda>:3/end_time',\n",
      "  'value': '2024-01-06T03:12:43.100+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/<lambda>:4/final_output',\n",
      "  'value': {'output': [AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}}),\n",
      "                       FunctionMessage(content=\"[Document(page_content='cats like fish'), Document(page_content='dogs like sticks')]\", name='get_eugene_thoughts')]}},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/<lambda>:4/end_time',\n",
      "  'value': '2024-01-06T03:12:43.100+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/RunnableParallel<input,agent_scratchpad>:2/final_output',\n",
      "  'value': {'agent_scratchpad': [AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}}),\n",
      "                                 FunctionMessage(content=\"[Document(page_content='cats like fish'), Document(page_content='dogs like sticks')]\", name='get_eugene_thoughts')],\n",
      "            'input': 'what does eugene think about cats?'}},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/RunnableParallel<input,agent_scratchpad>:2/end_time',\n",
      "  'value': '2024-01-06T03:12:43.101+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/ChatPromptTemplate:2',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '724c5bf8-d475-45ec-a69a-a4f188dc405f',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'ChatPromptTemplate',\n",
      "            'start_time': '2024-01-06T03:12:43.101+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['seq:step:2'],\n",
      "            'type': 'prompt'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/ChatPromptTemplate:2/final_output',\n",
      "  'value': {'messages': [SystemMessage(content='You are a helpful assistant.'),\n",
      "                         HumanMessage(content='what does eugene think about cats?'),\n",
      "                         AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}}),\n",
      "                         FunctionMessage(content=\"[Document(page_content='cats like fish'), Document(page_content='dogs like sticks')]\", name='get_eugene_thoughts')]}},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/ChatPromptTemplate:2/end_time',\n",
      "  'value': '2024-01-06T03:12:43.102+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/LLM:2',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '4542ae99-f854-41be-9669-41d8cd7dfb24',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'LLM',\n",
      "            'start_time': '2024-01-06T03:12:43.103+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['seq:step:3'],\n",
      "            'type': 'llm'}})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': 'E'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='E')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': 'ug'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='ug')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': 'ene'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='ene')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ' thinks'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content=' thinks')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ' that'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content=' that')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ' cats'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content=' cats')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ' like'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content=' like')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ' fish'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content=' fish')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': '.'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='.')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='')})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/LLM:2/final_output',\n",
      "  'value': LLMResult(generations=[[ChatGeneration(text='Eugene thinks that cats like fish.', generation_info={'finish_reason': 'stop'}, message=AIMessage(content='Eugene thinks that cats like fish.'))]], llm_output=None, run=None)},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/end_time',\n",
      "  'value': '2024-01-06T03:12:43.776+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/OpenAIFunctionsAgentOutputParser:2',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '281c8ae8-dbc6-433f-86c8-20b86b3c8eee',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'OpenAIFunctionsAgentOutputParser',\n",
      "            'start_time': '2024-01-06T03:12:43.776+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['seq:step:4'],\n",
      "            'type': 'parser'}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/OpenAIFunctionsAgentOutputParser:2/final_output',\n",
      "  'value': AgentFinish(return_values={'output': 'Eugene thinks that cats like fish.'}, log='Eugene thinks that cats like fish.')},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/OpenAIFunctionsAgentOutputParser:2/end_time',\n",
      "  'value': '2024-01-06T03:12:43.777+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/RunnableSequence:2/final_output',\n",
      "  'value': {'output': AgentFinish(return_values={'output': 'Eugene thinks that cats like fish.'}, log='Eugene thinks that cats like fish.')}},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/RunnableSequence:2/end_time',\n",
      "  'value': '2024-01-06T03:12:43.778+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/streamed_output/-',\n",
      "  'value': {'messages': [AIMessage(content='Eugene thinks that cats like fish.')],\n",
      "            'output': 'Eugene thinks that cats like fish.'}},\n",
      " {'op': 'add',\n",
      "  'path': '/final_output/output',\n",
      "  'value': 'Eugene thinks that cats like fish.'},\n",
      " {'op': 'add',\n",
      "  'path': '/final_output/messages/2',\n",
      "  'value': AIMessage(content='Eugene thinks that cats like fish.')})\n"
     ]
    }
   ],
   "source": [
    "async for chunk in remote_runnable.astream_log({\"input\": \"what does eugene think about cats?\"}):\n",
    "    print(chunk)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "RunLogPatch({'op': 'replace',\n",
      "  'path': '',\n",
      "  'value': {'final_output': None,\n",
      "            'id': '51c65021-1b40-4a45-81b3-95fc5c5b545a',\n",
      "            'logs': {},\n",
      "            'streamed_output': []}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/LLM',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '7a34b2a3-d6c0-4a0b-9939-2bde70a98958',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'LLM',\n",
      "            'start_time': '2024-01-06T03:12:43.812+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['seq:step:3'],\n",
      "            'type': 'llm'}})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': ''}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': '{\\n'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': ' '}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': ' \"'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': 'query'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': '\":'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': ' \"'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': 'cats'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': '\"\\n'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='', additional_kwargs={'function_call': {'arguments': '}'}})})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='')})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/LLM/final_output',\n",
      "  'value': LLMResult(generations=[[ChatGeneration(generation_info={'finish_reason': 'function_call'}, message=AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}}))]], llm_output=None, run=None)},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM/end_time',\n",
      "  'value': '2024-01-06T03:12:44.588+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/streamed_output/-',\n",
      "  'value': {'actions': [AgentActionMessageLog(tool='get_eugene_thoughts', tool_input={'query': 'cats'}, log=\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})])],\n",
      "            'messages': [AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})]}},\n",
      " {'op': 'replace',\n",
      "  'path': '/final_output',\n",
      "  'value': {'actions': [AgentActionMessageLog(tool='get_eugene_thoughts', tool_input={'query': 'cats'}, log=\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})])],\n",
      "            'messages': [AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})]}})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/streamed_output/-',\n",
      "  'value': {'messages': [FunctionMessage(content=\"[Document(page_content='cats like fish'), Document(page_content='dogs like sticks')]\", name='get_eugene_thoughts')],\n",
      "            'steps': [{'action': AgentActionMessageLog(tool='get_eugene_thoughts', tool_input={'query': 'cats'}, log=\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})]),\n",
      "                       'observation': [Document(page_content='cats like fish'),\n",
      "                                       Document(page_content='dogs like sticks')]}]}},\n",
      " {'op': 'add',\n",
      "  'path': '/final_output/steps',\n",
      "  'value': [{'action': AgentActionMessageLog(tool='get_eugene_thoughts', tool_input={'query': 'cats'}, log=\"\\nInvoking: `get_eugene_thoughts` with `{'query': 'cats'}`\\n\\n\\n\", message_log=[AIMessage(content='', additional_kwargs={'function_call': {'name': 'get_eugene_thoughts', 'arguments': '{\\n  \"query\": \"cats\"\\n}'}})]),\n",
      "             'observation': [Document(page_content='cats like fish'),\n",
      "                             Document(page_content='dogs like sticks')]}]},\n",
      " {'op': 'add',\n",
      "  'path': '/final_output/messages/1',\n",
      "  'value': FunctionMessage(content=\"[Document(page_content='cats like fish'), Document(page_content='dogs like sticks')]\", name='get_eugene_thoughts')})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/LLM:2',\n",
      "  'value': {'end_time': None,\n",
      "            'final_output': None,\n",
      "            'id': '8ff3b248-fb7e-4305-bd57-54e21a85bacb',\n",
      "            'metadata': {'__langserve_endpoint': 'stream_log',\n",
      "                         '__langserve_version': '0.0.37',\n",
      "                         '__useragent': 'python-httpx/0.25.2'},\n",
      "            'name': 'LLM',\n",
      "            'start_time': '2024-01-06T03:12:44.756+00:00',\n",
      "            'streamed_output': [],\n",
      "            'streamed_output_str': [],\n",
      "            'tags': ['seq:step:3'],\n",
      "            'type': 'llm'}})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': 'E'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='E')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': 'ug'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='ug')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': 'ene'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='ene')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ' thinks'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content=' thinks')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ' that'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content=' that')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ' cats'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content=' cats')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ' like'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content=' like')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ' fish'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content=' fish')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': '.'},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='.')})\n",
      "RunLogPatch({'op': 'add', 'path': '/logs/LLM:2/streamed_output_str/-', 'value': ''},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/streamed_output/-',\n",
      "  'value': AIMessageChunk(content='')})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/logs/LLM:2/final_output',\n",
      "  'value': LLMResult(generations=[[ChatGeneration(text='Eugene thinks that cats like fish.', generation_info={'finish_reason': 'stop'}, message=AIMessage(content='Eugene thinks that cats like fish.'))]], llm_output=None, run=None)},\n",
      " {'op': 'add',\n",
      "  'path': '/logs/LLM:2/end_time',\n",
      "  'value': '2024-01-06T03:12:45.171+00:00'})\n",
      "RunLogPatch({'op': 'add',\n",
      "  'path': '/streamed_output/-',\n",
      "  'value': {'messages': [AIMessage(content='Eugene thinks that cats like fish.')],\n",
      "            'output': 'Eugene thinks that cats like fish.'}},\n",
      " {'op': 'add',\n",
      "  'path': '/final_output/output',\n",
      "  'value': 'Eugene thinks that cats like fish.'},\n",
      " {'op': 'add',\n",
      "  'path': '/final_output/messages/2',\n",
      "  'value': AIMessage(content='Eugene thinks that cats like fish.')})\n"
     ]
    }
   ],
   "source": [
    "async for chunk in remote_runnable.astream_log({\"input\": \"what does eugene think about cats?\"}, include_names=[\"LLM\"]):\n",
    "    print(chunk)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
